<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>编辑微信个性签名</title>
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../assets/style/admin.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <script src="../assets/layui/layui.js"></script>
    <script src="../assets/js/common.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../common/header.js"></script>
    <!-- 内容主体区域 -->
    <div id="LAY_app_body">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            编辑微信个性签名
                        </div>
                        <div class="layui-card-body">
                            <form class="layui-form" action="" onsubmit="return false;">
                                <input type="hidden" name="id" value="">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">个性签名</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入个性签名" class="layui-input" value="">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">重复使用</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="reuse" value="1" title="是" >
                                        <input type="radio" name="reuse" value="0" title="否" checked>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="formSubmit">保存</button>
                                        <a class="layui-btn layui-btn-primary" href="../user_wechat_nickname/index.html">取消</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['form'], function(){
            var $ = layui.$
                ,form = layui.form;

            form.verify({
                name: function(value){
                    if (value.length < 1) {
                        return '请输入昵称';
                    }
                }
            });

            //监听提交
            form.on('submit(formSubmit)', function(data){
                layer.msg('提交中', {
                    shadeClose: false
                    ,icon: 16
                    ,shade: 0.01
                });
                $.ajax({
                    type: "POST",
                    url: "/user_wechat_sign/single_save",
                    data: data.field,
                    success:function(response){
                        var dataObj=$.parseJSON(response);
                        if (dataObj.code===0) {
                            layer.msg('数据提交成功', {icon: 6});
                            var targetUrl = '/user_wechat_sign/index';
                            setTimeout(function(){
                                location.href = targetUrl;
                            }, 1000);
                        } else {
                            layer.msg(dataObj.msg, {icon: 5});
                        }
                    },
                    error: function (request, status, error) {
                        layer.msg('哦噢，网络开小差了', {icon: 5});
                    }
                });
                return false;
            });
        });
    </script>
</div>
</body>
</html>
